home *** CD-ROM | disk | FTP | other *** search
/ 3D Games (Spidla) / 3dhry2.iso / Tank Wars 3D / src / RENDER.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  2003-03-17  |  76.0 KB  |  1,606 lines

  1. #include <math.h>
  2.  
  3. #include "tankwars.h"
  4.  
  5. extern HDC hDC;
  6. extern GLuint texture[TOTAL_TEXTURES];
  7. extern GLuint model[TOTAL_MODELS];
  8.  
  9. extern int heightmap[31][21];
  10. extern unsigned char lightmap[30][20];
  11. extern int grid[30][20];
  12.  
  13. extern float explosionmap[20][20];
  14. // Brightness map affected by explosions. Values range from 0 to 1
  15. float brightmap[30][20];
  16.  
  17. extern float cameraangle;
  18.  
  19. extern int screen_h;
  20. extern int screen_w;
  21.  
  22. extern float fps;
  23.  
  24. void renderterrain(void);
  25. void rendergrid(void);
  26. void rendertanks(void);
  27. void rendermissles(void);
  28. void rendersmoke(void);
  29. void rendergrenades(void);
  30. void renderexplosions(void);
  31. void renderparticles(void);
  32. void renderdebris(void);
  33. void renderfog(void);
  34. void renderrain(void);
  35. void renderwall(void);
  36. void renderstatus(void);
  37.  
  38. void createbigexplosion(int xpos, int ypos);
  39.  
  40. extern c_player player[2];
  41.  
  42. extern c_explosion explosion[50];
  43. extern int nextexplosionslot;
  44.  
  45. extern c_missle missle[20];
  46. extern int nextmissleslot;
  47.  
  48. extern c_smoke smoke[50];
  49. extern int nextsmokeslot;
  50.  
  51. extern c_grenade grenade[20];
  52. extern int nextgrenadeslot;
  53.  
  54. extern c_particle particle[500];
  55. extern int nextparticleslot;
  56.  
  57. extern c_debris debris[100];
  58. extern int nextdebrisslot;
  59.  
  60. extern unsigned long wall;
  61.  
  62. c_rain rain[500];
  63.  
  64. extern int winner;
  65.  
  66. extern int fogenabled;
  67. extern int timeofday;
  68. extern int raindensity;
  69.  
  70. int DrawGLScene(GLvoid)
  71. {
  72.     int x, y, loop;
  73.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  74.  
  75.     // Position the origin to top left corner of grid
  76.     glLoadIdentity();
  77.     glTranslatef(0, 30, -350);
  78.     glRotatef(cameraangle, -1, 0, 0);
  79.     glTranslatef(-150, 100, 0);
  80.     glScalef(1, -1, 1);
  81.  
  82.     for(y=0; y<20; y++)
  83.     {
  84.         for(x=0; x<30; x++)
  85.         {
  86.             // If daytime:
  87.             if(timeofday==0)
  88.                 brightmap[x][y]=0.4f;
  89.             // If nighttime:
  90.             else
  91.                 brightmap[x][y]=0.0f;
  92.             for(loop=0; loop<50; loop++)
  93.             {
  94.                 if(explosion[loop].stage>0 && x>explosion[loop].pos.x-10 && x<explosion[loop].pos.x+10 && y>explosion[loop].pos.y-10 && y<explosion[loop].pos.y+10)
  95.                 {
  96.                     if(explosion[loop].stage<10)
  97.                         brightmap[x][y]+=explosionmap[x-explosion[loop].pos.x+10][y-explosion[loop].pos.y+10]*((float)explosion[loop].stage/(float)10)*0.5f;
  98.                     else
  99.                         brightmap[x][y]+=explosionmap[x-explosion[loop].pos.x+10][y-explosion[loop].pos.y+10]*((float)1-(float)(explosion[loop].stage-10)/(float)10)*0.5f;
  100.                 }
  101.             }
  102.         }
  103.     }
  104.  
  105.     rendergrid();
  106.     renderterrain();
  107.     rendermissles();
  108.     rendersmoke();
  109.     rendergrenades();
  110.     renderdebris();
  111.     renderwall();
  112.     rendertanks();
  113.     renderexplosions();
  114.     renderparticles();
  115.     renderrain();
  116.     renderfog();
  117.  
  118.     glDisable(GL_BLEND);
  119.     glDisable(GL_TEXTURE_2D);
  120.     glDisable(GL_DEPTH_TEST);
  121.     glBegin(GL_TRIANGLE_FAN);
  122.         glColor3f(0.0f, 0.0f, 0.0f);
  123.         glVertex3f(150, 500, 0);
  124.         for(x=30; x>=0; x--)
  125.         {
  126.             glVertex3f((float)(x*10), 200, (float)heightmap[x][20]);
  127.         }
  128.     glEnd();
  129.     glEnable(GL_DEPTH_TEST);
  130.     glEnable(GL_TEXTURE_2D);
  131.     glEnable(GL_BLEND);
  132.  
  133.     glLoadIdentity();
  134.     renderstatus();
  135.  
  136.     glColor3f(1.0f, 0.0f, 0.0f);
  137.     glPrint(0, 460, 0, "FPS: %d", (int)fps);
  138.  
  139.     glColor3f(0.0f, 1.0f, 0.0f);
  140.     glPrint(100, 460, 0, "Press <SPACE> to disable/enable frame rate limiter");
  141.  
  142.     glColor3f(1.0f, 1.0f, 0.0f);
  143.     glPrint(0, 440, 0, "Click and drag mouse to change view");
  144.  
  145.     glColor3f(0.8f, 0.8f, 0.8f);
  146.     glPrint(0, 420, 0, "Press 1 - 3 to toggle fog, rain, day/night");
  147.  
  148.     // Flush the data and swap the front and back buffers:
  149.     glFlush();
  150.     SwapBuffers(hDC);
  151.     return TRUE;
  152. }
  153.  
  154. void renderterrain(void)
  155. {
  156.     int x, y;
  157.     glBindTexture(GL_TEXTURE_2D, texture[GROUND_TEXTURE]);
  158.  
  159.     glBegin(GL_TRIANGLES);
  160.         for(y=0; y<20; y++)
  161.         {
  162.             for(x=0; x<30; x++)
  163.             {
  164.                 if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y && player[0].rebirth==0) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y && player[1].rebirth==0))
  165.                     if(grid[x][y]==EMPTY)
  166.                         glColor3f(0, (float)lightmap[x][y]/(float)255+brightmap[x][y], 0);
  167.                     else
  168.                         glColor3f((float)lightmap[x][y]/(float)255+brightmap[x][y], 0, 0);
  169.                 else
  170.                     glColor3f((float)lightmap[x][y]/(float)255+brightmap[x][y], (float)lightmap[x][y]/(float)255+brightmap[x][y], (float)lightmap[x][y]/(float)255+brightmap[x][y]);
  171.  
  172.                 glTexCoord2f((float)(x+1)/(float)30, (float)1-(float)y/(float)20);
  173.                 glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  174.                 glTexCoord2f((float)x/(float)30, (float)1-(float)y/(float)20);
  175.                 glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  176.                 glTexCoord2f((float)x/(float)30, (float)1-(float)(y+1)/(float)20);
  177.                 glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  178.  
  179.                 glTexCoord2f((float)x/(float)30, (float)1-(float)(y+1)/(float)20);
  180.                 glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  181.                 glTexCoord2f((float)(x+1)/(float)30, (float)1-(float)(y+1)/(float)20);
  182.                 glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  183.                 glTexCoord2f((float)(x+1)/(float)30, (float)1-(float)y/(float)20);
  184.                 glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  185.             }
  186.         }
  187.     glEnd();
  188. }
  189.  
  190. void rendergrid(void)
  191. {
  192.     int x, y;
  193.  
  194.     glDisable(GL_BLEND);
  195.  
  196.     // Draw all the MINE
  197.     glBindTexture(GL_TEXTURE_2D, texture[MINE_TEXTURE]);
  198.     glBegin(GL_QUADS);
  199.         for(y=0; y<20; y++)
  200.         {
  201.             for(x=0; x<30; x++)
  202.             {
  203.                 // Render MINE:
  204.                 if(grid[x][y]==MINE)
  205.                 {
  206.                     // Top Face:
  207.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  208.                         glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  209.                     else
  210.                         glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  211.                     glTexCoord2f(1.0f, 1.0f);
  212.                     glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]+1);
  213.                     glTexCoord2f(0.0f, 1.0f);
  214.                     glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]+1);
  215.                     glTexCoord2f(0.0f, 0.0f);
  216.                     glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]+1);
  217.                     glTexCoord2f(1.0f, 0.0f);
  218.                     glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]+1);
  219.                 }
  220.             }
  221.         }
  222.     glEnd();
  223.  
  224.     // Draw all of the BRICK1
  225.     glBindTexture(GL_TEXTURE_2D, texture[BRICK1_TEXTURE]);
  226.     glBegin(GL_QUADS);
  227.         for(y=0; y<20; y++)
  228.         {
  229.             for(x=0; x<30; x++)
  230.             {
  231.                 // Render BRICK:
  232.                 if(grid[x][y]==BRICK1)
  233.             {
  234.                     if(!(player[0].rebirth==0 && player[0].mode==MISSLE_MODE && (x>=(int)(player[0].pos.x/10)-1 && x<=(int)(player[0].pos.x/10)+1 && y>=(int)(player[0].pos.y/10)-1 && y<=(int)(player[0].pos.y/10)+1) ) &&
  235.                        !(player[1].rebirth==0 && player[1].mode==MISSLE_MODE && (x>=(int)(player[1].pos.x/10)-1 && x<=(int)(player[1].pos.x/10)+1 && y>=(int)(player[1].pos.y/10)-1 && y<=(int)(player[1].pos.y/10)+1) ))
  236.                     {
  237.                         // Front Face:
  238.                         if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  239.                         {
  240.                             if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  241.                                 glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  242.                             else
  243.                                 glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  244.                             glTexCoord2f(1.0f, 1.0f);
  245.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  246.                             glTexCoord2f(0.0f, 1.0f);
  247.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  248.                             glTexCoord2f(0.0f, 0.0f);
  249.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  250.                             glTexCoord2f(1.0f, 0.0f);
  251.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  252.                         }
  253.                         // Left Face:
  254.                         if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  255.                         {
  256.                             if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  257.                                 glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  258.                             else
  259.                                 glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  260.                             glTexCoord2f(1.0f, 1.0f);
  261.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  262.                             glTexCoord2f(0.0f, 1.0f);
  263.                             glVertex3f((float)(x*10), (float)(y*10), (float)10);
  264.                             glTexCoord2f(0.0f, 0.0f);
  265.                             glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  266.                             glTexCoord2f(1.0f, 0.0f);
  267.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  268.                         }
  269.                         // Right Face:
  270.                         if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  271.                         {
  272.                             if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  273.                                 glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  274.                             else
  275.                                 glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  276.                             glTexCoord2f(1.0f, 1.0f);
  277.                             glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  278.                             glTexCoord2f(0.0f, 1.0f);
  279.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  280.                             glTexCoord2f(0.0f, 0.0f);
  281.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  282.                             glTexCoord2f(1.0f, 0.0f);
  283.                             glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  284.                         }
  285.                         // Top Face:
  286.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  287.                             glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  288.                         else
  289.                             glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  290.                         glTexCoord2f(1.0f, 1.0f);
  291.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  292.                         glTexCoord2f(0.0f, 1.0f);
  293.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  294.                         glTexCoord2f(0.0f, 0.0f);
  295.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  296.                         glTexCoord2f(1.0f, 0.0f);
  297.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  298.                     }
  299.                 }
  300.             }
  301.         }
  302.     glEnd();
  303.  
  304.     // Draw all of the BRICK0
  305.     glBindTexture(GL_TEXTURE_2D, texture[BRICK0_TEXTURE]);
  306.     glBegin(GL_QUADS);
  307.         for(y=0; y<20; y++)
  308.         {
  309.             for(x=0; x<30; x++)
  310.             {
  311.                 // Render BRICK:
  312.                 if(grid[x][y]==BRICK0 && (player[0].mode!=MISSLE_MODE || !(player[0].buildpos.x==x && player[0].buildpos.y==y)) && (player[1].mode!=MISSLE_MODE || !(player[1].buildpos.x==x && player[1].buildpos.y==y)))
  313.                 {
  314.                     if(!(player[0].rebirth==0 && player[0].mode==MISSLE_MODE && (x>=(int)(player[0].pos.x/10)-1 && x<=(int)(player[0].pos.x/10)+1 && y>=(int)(player[0].pos.y/10)-1 && y<=(int)(player[0].pos.y/10)+1) ) &&
  315.                        !(player[1].rebirth==0 && player[1].mode==MISSLE_MODE && (x>=(int)(player[1].pos.x/10)-1 && x<=(int)(player[1].pos.x/10)+1 && y>=(int)(player[1].pos.y/10)-1 && y<=(int)(player[1].pos.y/10)+1) ))
  316.                     {
  317.                         // Front Face:
  318.                         if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  319.                         {
  320.                             if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  321.                                 glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  322.                             else
  323.                                 glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  324.                             glTexCoord2f(1.0f, 1.0f);
  325.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  326.                             glTexCoord2f(0.0f, 1.0f);
  327.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  328.                             glTexCoord2f(0.0f, 0.0f);
  329.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  330.                             glTexCoord2f(1.0f, 0.0f);
  331.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  332.                         }
  333.                         // Left Face:
  334.                         if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  335.                         {
  336.                             if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  337.                                 glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  338.                             else
  339.                                 glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  340.                             glTexCoord2f(1.0f, 1.0f);
  341.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  342.                             glTexCoord2f(0.0f, 1.0f);
  343.                             glVertex3f((float)(x*10), (float)(y*10), (float)10);
  344.                             glTexCoord2f(0.0f, 0.0f);
  345.                             glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  346.                             glTexCoord2f(1.0f, 0.0f);
  347.                             glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  348.                         }
  349.                         // Right Face:
  350.                         if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  351.                         {
  352.                             if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  353.                                 glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  354.                             else
  355.                                 glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  356.                             glTexCoord2f(1.0f, 1.0f);
  357.                             glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  358.                             glTexCoord2f(0.0f, 1.0f);
  359.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  360.                             glTexCoord2f(0.0f, 0.0f);
  361.                             glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  362.                             glTexCoord2f(1.0f, 0.0f);
  363.                             glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  364.                         }
  365.                         // Top Face:
  366.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  367.                             glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  368.                         else
  369.                             glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  370.                         glTexCoord2f(1.0f, 1.0f);
  371.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  372.                         glTexCoord2f(0.0f, 1.0f);
  373.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  374.                         glTexCoord2f(0.0f, 0.0f);
  375.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  376.                         glTexCoord2f(1.0f, 0.0f);
  377.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  378.                     }
  379.                 }
  380.             }
  381.         }
  382.     glEnd();
  383.     // Draw all of the TRUNK
  384.     glBindTexture(GL_TEXTURE_2D, texture[TRUNK_TEXTURE]);
  385.     glBegin(GL_QUADS);
  386.         for(y=0; y<20; y++)
  387.         {
  388.             for(x=0; x<30; x++)
  389.             {
  390.                 // Render TRUNK:
  391.                 if(grid[x][y]==TRUNK)
  392.                 {
  393.  
  394.                     // Front Face:
  395.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  396.                         glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  397.                     else
  398.                         glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  399.                     glTexCoord2f(1.0f, 1.0f);
  400.                     glVertex3f((float)(x*10+7), (float)(y*10+7), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  401.                     glTexCoord2f(0.0f, 1.0f);
  402.                     glVertex3f((float)(x*10+3), (float)(y*10+7), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  403.                     glTexCoord2f(0.0f, 0.0f);
  404.                     glVertex3f((float)(x*10+3), (float)(y*10+7), (float)0);
  405.                     glTexCoord2f(1.0f, 0.0f);
  406.                     glVertex3f((float)(x*10+7), (float)(y*10+7), (float)0);
  407.                     // Left Face:
  408.                     if(x>15)
  409.                     {
  410.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  411.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  412.                         else
  413.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  414.                         glTexCoord2f(1.0f, 1.0f);
  415.                         glVertex3f((float)(x*10+3), (float)(y*10+7), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  416.                         glTexCoord2f(0.0f, 1.0f);
  417.                         glVertex3f((float)(x*10+3), (float)(y*10+3), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  418.                         glTexCoord2f(0.0f, 0.0f);
  419.                         glVertex3f((float)(x*10+3), (float)(y*10+3), (float)0);
  420.                         glTexCoord2f(1.0f, 0.0f);
  421.                         glVertex3f((float)(x*10+3), (float)(y*10+7), (float)0);
  422.                     }
  423.                     // Right Face:
  424.                     if(x<15)
  425.                     {
  426.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  427.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  428.                         else
  429.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  430.                         glTexCoord2f(1.0f, 1.0f);
  431.                         glVertex3f((float)(x*10+7), (float)(y*10+3), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  432.                         glTexCoord2f(0.0f, 1.0f);
  433.                         glVertex3f((float)(x*10+7), (float)(y*10+7), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  434.                         glTexCoord2f(0.0f, 0.0f);
  435.                         glVertex3f((float)(x*10+7), (float)(y*10+7), (float)0);
  436.                         glTexCoord2f(1.0f, 0.0f);
  437.                         glVertex3f((float)(x*10+7), (float)(y*10+3), (float)0);
  438.                     }
  439.                     // Top Face:
  440.                     if(grid[x][y]==TRUNK)
  441.                     {
  442.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  443.                             glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  444.                         else
  445.                             glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  446.                         glTexCoord2f(1.0f, 1.0f);
  447.                         glVertex3f((float)(x*10+7), (float)(y*10+3), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  448.                         glTexCoord2f(0.0f, 1.0f);
  449.                         glVertex3f((float)(x*10+3), (float)(y*10+3), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  450.                         glTexCoord2f(0.0f, 0.0f);
  451.                         glVertex3f((float)(x*10+3), (float)(y*10+7), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  452.                         glTexCoord2f(1.0f, 0.0f);
  453.                         glVertex3f((float)(x*10+7), (float)(y*10+7), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  454.                     }
  455.                 }
  456.             }
  457.         }
  458.     glEnd();
  459.     // Draw all of the TREE
  460.     glEnable(GL_CULL_FACE);
  461.     glBindTexture(GL_TEXTURE_2D, texture[TREE_TEXTURE]);
  462.     glBegin(GL_TRIANGLES);
  463.         for(y=0; y<20; y++)
  464.         {
  465.             for(x=0; x<30; x++)
  466.             {
  467.                 // Render TREE:
  468.                 if(grid[x][y]==TREE)
  469.                 {
  470.  
  471.                     // Front Face:
  472.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  473.                         glColor3f(0.3f+brightmap[x][y], 0.0f, 0.0f);
  474.                     else
  475.                         glColor3f(0.3f+brightmap[x][y], 0.3f+brightmap[x][y], 0.3f+brightmap[x][y]);
  476.                     glTexCoord2f(0.5f, 1.0f);
  477.                     glVertex3f((float)(x*10+5), (float)(y*10+5), (float)(19+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  478.                     glTexCoord2f(0.0f, 0.0f);
  479.                     glVertex3f((float)(x*10+1), (float)(y*10+9), (float)(3+heightmap[x][y+1]));
  480.                     glTexCoord2f(1.0f, 0.0f);
  481.                     glVertex3f((float)(x*10+9), (float)(y*10+9), (float)(3+heightmap[x+1][y+1]));
  482.                     // Back Face:
  483.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  484.                         glColor3f(0.3f+brightmap[x][y], 0.0f, 0.0f);
  485.                     else
  486.                         glColor3f(0.3f+brightmap[x][y], 0.3f+brightmap[x][y], 0.3f+brightmap[x][y]);
  487.                     glTexCoord2f(0.5f, 1.0f);
  488.                     glVertex3f((float)(x*10+5), (float)(y*10+5), (float)(19+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  489.                     glTexCoord2f(0.0f, 0.0f);
  490.                     glVertex3f((float)(x*10+9), (float)(y*10+1), (float)(3+heightmap[x+1][y]));
  491.                     glTexCoord2f(1.0f, 0.0f);
  492.                     glVertex3f((float)(x*10+1), (float)(y*10+1), (float)(3+heightmap[x][y]));
  493.                     // Left Face:
  494.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  495.                         glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  496.                     else
  497.                         glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  498.                     glTexCoord2f(0.5f, 1.0f);
  499.                     glVertex3f((float)(x*10+5), (float)(y*10+5), (float)(19+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  500.                     glTexCoord2f(0.0f, 0.0f);
  501.                     glVertex3f((float)(x*10+1), (float)(y*10+1), (float)(3+heightmap[x][y]));
  502.                     glTexCoord2f(1.0f, 0.0f);
  503.                     glVertex3f((float)(x*10+1), (float)(y*10+9), (float)(3+heightmap[x][y+1]));
  504.                     // Right Face:
  505.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  506.                         glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  507.                     else
  508.                         glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  509.                     glTexCoord2f(0.5f, 1.0f);
  510.                     glVertex3f((float)(x*10+5), (float)(y*10+5), (float)(19+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  511.                     glTexCoord2f(0.0f, 0.0f);
  512.                     glVertex3f((float)(x*10+9), (float)(y*10+9), (float)(3+heightmap[x+1][y+1]));
  513.                     glTexCoord2f(1.0f, 0.0f);
  514.                     glVertex3f((float)(x*10+9), (float)(y*10+1), (float)(3+heightmap[x+1][y]));
  515.                 }
  516.             }
  517.         }
  518.     glEnd();
  519.     glDisable(GL_CULL_FACE);
  520.     // Draw all of the REDFLAG and BLUEFLAG
  521.     glDisable(GL_TEXTURE_2D);
  522.     glBegin(GL_QUADS);
  523.         for(y=0; y<20; y++)
  524.         {
  525.             for(x=0; x<30; x++)
  526.             {
  527.                 // Render REDFLAG and BLUEFLAG:
  528.                 if(grid[x][y]==REDFLAG || grid[x][y]==BLUEFLAG)
  529.                 {
  530.  
  531.                     // Flag Face:
  532.                     if(grid[x][y]==REDFLAG)
  533.                     {
  534.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  535.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  536.                         else
  537.                             glColor3f(0.6f+brightmap[x][y], 0.0f, 0.0f);
  538.                     }
  539.                     else
  540.                     {
  541.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  542.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  543.                         else
  544.                             glColor3f(0.0f, 0.0f, 0.6f+brightmap[x][y]);
  545.                     }
  546.                     glVertex3f((float)(x*10+9), (float)(y*10+5), (float)(12+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  547.                     glVertex3f((float)(x*10+1), (float)(y*10+5), (float)(12+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  548.                     glVertex3f((float)(x*10+1), (float)(y*10+5), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  549.                     glVertex3f((float)(x*10+9), (float)(y*10+5), (float)(5+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  550.                     // Pole:
  551.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  552.                         glColor3f(0.3f+brightmap[x][y], 0.0f, 0.0f);
  553.                     else
  554.                         glColor3f(0.3f+brightmap[x][y], 0.3f+brightmap[x][y], 0.3f+brightmap[x][y]);
  555.                     glVertex3f((float)(x*10+1), (float)(y*10+5), (float)(12+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  556.                     glVertex3f((float)(x*10), (float)(y*10+5), (float)(12+(heightmap[x][y]+heightmap[x+1][y]+heightmap[x][y+1]+heightmap[x+1][y+1])/4));
  557.                     glVertex3f((float)(x*10), (float)(y*10+5), (float)0);
  558.                     glVertex3f((float)(x*10+1), (float)(y*10+5), (float)0);
  559.                 }
  560.             }
  561.         }
  562.     glEnd();
  563.     // Draw all of the REDGATE and BLUEGATE
  564.     glBegin(GL_LINES);
  565.         for(y=0; y<20; y++)
  566.         {
  567.             for(x=0; x<30; x++)
  568.             {
  569.                 // Render REDFLAG and BLUEFLAG:
  570.                 if(grid[x][y]==REDGATE || grid[x][y]==BLUEGATE)
  571.                 {
  572.                     if(grid[x][y]==REDGATE)
  573.                     {
  574.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  575.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  576.                         else
  577.                             glColor3f(0.6f+brightmap[x][y], 0.0f, 0.0f);
  578.                     }
  579.                     else
  580.                     {
  581.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  582.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  583.                         else
  584.                             glColor3f(0.0f, 0.0f, 0.6f+brightmap[x][y]);
  585.                     }
  586.                     glVertex3f((float)(x*10+5), (float)(y*10), (float)10);
  587.                     glVertex3f((float)(x*10+5), (float)(y*10), (float)0);
  588.                     glVertex3f((float)(x*10+5), (float)(y*10+10), (float)10);
  589.                     glVertex3f((float)(x*10+5), (float)(y*10+10), (float)0);
  590.                     glVertex3f((float)(x*10), (float)(y*10+5), (float)10);
  591.                     glVertex3f((float)(x*10), (float)(y*10+5), (float)0);
  592.                     glVertex3f((float)(x*10+10), (float)(y*10+5), (float)10);
  593.                     glVertex3f((float)(x*10+10), (float)(y*10+5), (float)0);
  594.                     glVertex3f((float)(x*10+5), (float)(y*10), (float)10);
  595.                     glVertex3f((float)(x*10+5), (float)(y*10+10), (float)10);
  596.                     glVertex3f((float)(x*10), (float)(y*10+5), (float)10);
  597.                     glVertex3f((float)(x*10+10), (float)(y*10+5), (float)10);
  598.                     glVertex3f((float)(x*10+5), (float)(y*10), (float)6);
  599.                     glVertex3f((float)(x*10+5), (float)(y*10+10), (float)6);
  600.                     glVertex3f((float)(x*10), (float)(y*10+5), (float)6);
  601.                     glVertex3f((float)(x*10+10), (float)(y*10+5), (float)6);
  602.                 }
  603.             }
  604.         }
  605.     glEnd();
  606.     glEnable(GL_TEXTURE_2D);
  607.  
  608.     // Draw all of the LIFE_POWERUP
  609.     glBindTexture(GL_TEXTURE_2D, texture[LIFE_POWERUP_TEXTURE]);
  610.     glBegin(GL_QUADS);
  611.         for(y=0; y<20; y++)
  612.         {
  613.             for(x=0; x<30; x++)
  614.             {
  615.                 // Render LIFE_POWERUP:
  616.                 if(grid[x][y]==LIFE_POWERUP)
  617.                 {
  618.  
  619.                     // Front Face:
  620.                     if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  621.                     {
  622.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  623.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  624.                         else
  625.                             glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  626.                         glTexCoord2f(1.0f, 1.0f);
  627.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  628.                         glTexCoord2f(0.0f, 1.0f);
  629.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  630.                         glTexCoord2f(0.0f, 0.0f);
  631.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  632.                         glTexCoord2f(1.0f, 0.0f);
  633.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  634.                     }
  635.                     // Left Face:
  636.                     if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  637.                     {
  638.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  639.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  640.                         else
  641.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  642.                         glTexCoord2f(1.0f, 1.0f);
  643.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  644.                         glTexCoord2f(0.0f, 1.0f);
  645.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  646.                         glTexCoord2f(0.0f, 0.0f);
  647.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  648.                         glTexCoord2f(1.0f, 0.0f);
  649.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  650.                     }
  651.                     // Right Face:
  652.                     if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  653.                     {
  654.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  655.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  656.                         else
  657.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  658.                         glTexCoord2f(1.0f, 1.0f);
  659.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  660.                         glTexCoord2f(0.0f, 1.0f);
  661.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  662.                         glTexCoord2f(0.0f, 0.0f);
  663.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  664.                         glTexCoord2f(1.0f, 0.0f);
  665.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  666.                     }
  667.                     // Top Face:
  668.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  669.                         glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  670.                     else
  671.                         glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  672.                     glTexCoord2f(1.0f, 1.0f);
  673.                     glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  674.                     glTexCoord2f(0.0f, 1.0f);
  675.                     glVertex3f((float)(x*10), (float)(y*10), (float)10);
  676.                     glTexCoord2f(0.0f, 0.0f);
  677.                     glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  678.                     glTexCoord2f(1.0f, 0.0f);
  679.                     glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  680.                 }
  681.             }
  682.         }
  683.     glEnd();
  684.     // Draw all of the BRICK_POWERUP
  685.     glBindTexture(GL_TEXTURE_2D, texture[BRICK_POWERUP_TEXTURE]);
  686.     glBegin(GL_QUADS);
  687.         for(y=0; y<20; y++)
  688.         {
  689.             for(x=0; x<30; x++)
  690.             {
  691.                 // Render LIFE_POWERUP:
  692.                 if(grid[x][y]==BRICK_POWERUP)
  693.                 {
  694.  
  695.                     // Front Face:
  696.                     if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  697.                     {
  698.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  699.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  700.                         else
  701.                             glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  702.                         glTexCoord2f(1.0f, 1.0f);
  703.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  704.                         glTexCoord2f(0.0f, 1.0f);
  705.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  706.                         glTexCoord2f(0.0f, 0.0f);
  707.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  708.                         glTexCoord2f(1.0f, 0.0f);
  709.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  710.                     }
  711.                     // Left Face:
  712.                     if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  713.                     {
  714.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  715.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  716.                         else
  717.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  718.                         glTexCoord2f(1.0f, 1.0f);
  719.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  720.                         glTexCoord2f(0.0f, 1.0f);
  721.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  722.                         glTexCoord2f(0.0f, 0.0f);
  723.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  724.                         glTexCoord2f(1.0f, 0.0f);
  725.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  726.                     }
  727.                     // Right Face:
  728.                     if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  729.                     {
  730.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  731.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  732.                         else
  733.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  734.                         glTexCoord2f(1.0f, 1.0f);
  735.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  736.                         glTexCoord2f(0.0f, 1.0f);
  737.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  738.                         glTexCoord2f(0.0f, 0.0f);
  739.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  740.                         glTexCoord2f(1.0f, 0.0f);
  741.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  742.                     }
  743.                     // Top Face:
  744.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  745.                         glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  746.                     else
  747.                         glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  748.                     glTexCoord2f(1.0f, 1.0f);
  749.                     glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  750.                     glTexCoord2f(0.0f, 1.0f);
  751.                     glVertex3f((float)(x*10), (float)(y*10), (float)10);
  752.                     glTexCoord2f(0.0f, 0.0f);
  753.                     glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  754.                     glTexCoord2f(1.0f, 0.0f);
  755.                     glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  756.                 }
  757.             }
  758.         }
  759.     glEnd();
  760.     // Draw all of the MINE_POWERUP
  761.     glBindTexture(GL_TEXTURE_2D, texture[MINE_POWERUP_TEXTURE]);
  762.     glBegin(GL_QUADS);
  763.         for(y=0; y<20; y++)
  764.         {
  765.             for(x=0; x<30; x++)
  766.             {
  767.                 // Render LIFE_POWERUP:
  768.                 if(grid[x][y]==MINE_POWERUP)
  769.                 {
  770.  
  771.                     // Front Face:
  772.                     if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  773.                     {
  774.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  775.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  776.                         else
  777.                             glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  778.                         glTexCoord2f(1.0f, 1.0f);
  779.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  780.                         glTexCoord2f(0.0f, 1.0f);
  781.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  782.                         glTexCoord2f(0.0f, 0.0f);
  783.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  784.                         glTexCoord2f(1.0f, 0.0f);
  785.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  786.                     }
  787.                     // Left Face:
  788.                     if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  789.                     {
  790.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  791.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  792.                         else
  793.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  794.                         glTexCoord2f(1.0f, 1.0f);
  795.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  796.                         glTexCoord2f(0.0f, 1.0f);
  797.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  798.                         glTexCoord2f(0.0f, 0.0f);
  799.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  800.                         glTexCoord2f(1.0f, 0.0f);
  801.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  802.                     }
  803.                     // Right Face:
  804.                     if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  805.                     {
  806.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  807.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  808.                         else
  809.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  810.                         glTexCoord2f(1.0f, 1.0f);
  811.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  812.                         glTexCoord2f(0.0f, 1.0f);
  813.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  814.                         glTexCoord2f(0.0f, 0.0f);
  815.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  816.                         glTexCoord2f(1.0f, 0.0f);
  817.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  818.                     }
  819.                     // Top Face:
  820.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  821.                         glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  822.                     else
  823.                         glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  824.                     glTexCoord2f(1.0f, 1.0f);
  825.                     glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  826.                     glTexCoord2f(0.0f, 1.0f);
  827.                     glVertex3f((float)(x*10), (float)(y*10), (float)10);
  828.                     glTexCoord2f(0.0f, 0.0f);
  829.                     glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  830.                     glTexCoord2f(1.0f, 0.0f);
  831.                     glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  832.                 }
  833.             }
  834.         }
  835.     glEnd();
  836.     // Draw all of the MISSLE_POWERUP
  837.     glBindTexture(GL_TEXTURE_2D, texture[MISSLE_POWERUP_TEXTURE]);
  838.     glBegin(GL_QUADS);
  839.         for(y=0; y<20; y++)
  840.         {
  841.             for(x=0; x<30; x++)
  842.             {
  843.                 // Render LIFE_POWERUP:
  844.                 if(grid[x][y]==MISSLE_POWERUP)
  845.                 {
  846.  
  847.                     // Front Face:
  848.                     if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  849.                     {
  850.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  851.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  852.                         else
  853.                             glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  854.                         glTexCoord2f(1.0f, 1.0f);
  855.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  856.                         glTexCoord2f(0.0f, 1.0f);
  857.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  858.                         glTexCoord2f(0.0f, 0.0f);
  859.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  860.                         glTexCoord2f(1.0f, 0.0f);
  861.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  862.                     }
  863.                     // Left Face:
  864.                     if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  865.                     {
  866.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  867.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  868.                         else
  869.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  870.                         glTexCoord2f(1.0f, 1.0f);
  871.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  872.                         glTexCoord2f(0.0f, 1.0f);
  873.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  874.                         glTexCoord2f(0.0f, 0.0f);
  875.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  876.                         glTexCoord2f(1.0f, 0.0f);
  877.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  878.                     }
  879.                     // Right Face:
  880.                     if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  881.                     {
  882.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  883.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  884.                         else
  885.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  886.                         glTexCoord2f(1.0f, 1.0f);
  887.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  888.                         glTexCoord2f(0.0f, 1.0f);
  889.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  890.                         glTexCoord2f(0.0f, 0.0f);
  891.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  892.                         glTexCoord2f(1.0f, 0.0f);
  893.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  894.                     }
  895.                     // Top Face:
  896.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  897.                         glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  898.                     else
  899.                         glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  900.                     glTexCoord2f(1.0f, 1.0f);
  901.                     glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  902.                     glTexCoord2f(0.0f, 1.0f);
  903.                     glVertex3f((float)(x*10), (float)(y*10), (float)10);
  904.                     glTexCoord2f(0.0f, 0.0f);
  905.                     glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  906.                     glTexCoord2f(1.0f, 0.0f);
  907.                     glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  908.                 }
  909.             }
  910.         }
  911.     glEnd();
  912.     // Draw all of the GRENADE_POWERUP
  913.     glBindTexture(GL_TEXTURE_2D, texture[GRENADE_POWERUP_TEXTURE]);
  914.     glBegin(GL_QUADS);
  915.         for(y=0; y<20; y++)
  916.         {
  917.             for(x=0; x<30; x++)
  918.             {
  919.                 // Render LIFE_POWERUP:
  920.                 if(grid[x][y]==GRENADE_POWERUP)
  921.                 {
  922.  
  923.                     // Front Face:
  924.                     if(y==19 || (grid[x][y+1]!=BRICK1 && grid[x][y+1]!=BRICK0))
  925.                     {
  926.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  927.                             glColor3f(0.2f+brightmap[x][y], 0.0f, 0.0f);
  928.                         else
  929.                             glColor3f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y]);
  930.                         glTexCoord2f(1.0f, 1.0f);
  931.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  932.                         glTexCoord2f(0.0f, 1.0f);
  933.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  934.                         glTexCoord2f(0.0f, 0.0f);
  935.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  936.                         glTexCoord2f(1.0f, 0.0f);
  937.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  938.                     }
  939.                     // Left Face:
  940.                     if((x==0 || (grid[x-1][y]!=BRICK1 && grid[x-1][y]!=BRICK1)) && x>15)
  941.                     {
  942.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  943.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  944.                         else
  945.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  946.                         glTexCoord2f(1.0f, 1.0f);
  947.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  948.                         glTexCoord2f(0.0f, 1.0f);
  949.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  950.                         glTexCoord2f(0.0f, 0.0f);
  951.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  952.                         glTexCoord2f(1.0f, 0.0f);
  953.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  954.                     }
  955.                     // Right Face:
  956.                     if((x==29 || (grid[x+1][y]!=BRICK1 && grid[x+1][y]!=BRICK1)) && x<15)
  957.                     {
  958.                         if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  959.                             glColor3f(0.1f+brightmap[x][y], 0.0f, 0.0f);
  960.                         else
  961.                             glColor3f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y]);
  962.                         glTexCoord2f(1.0f, 1.0f);
  963.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  964.                         glTexCoord2f(0.0f, 1.0f);
  965.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  966.                         glTexCoord2f(0.0f, 0.0f);
  967.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  968.                         glTexCoord2f(1.0f, 0.0f);
  969.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  970.                     }
  971.                     // Top Face:
  972.                     if(((player[0].mode==BRICK_MODE || player[0].mode==MINE_MODE) && x==player[0].buildpos.x && y==player[0].buildpos.y) || ((player[1].mode==BRICK_MODE || player[1].mode==MINE_MODE) && x==player[1].buildpos.x && y==player[1].buildpos.y))
  973.                         glColor3f(0.4f+brightmap[x][y], 0.0f, 0.0f);
  974.                     else
  975.                         glColor3f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y]);
  976.                     glTexCoord2f(1.0f, 1.0f);
  977.                     glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  978.                     glTexCoord2f(0.0f, 1.0f);
  979.                     glVertex3f((float)(x*10), (float)(y*10), (float)10);
  980.                     glTexCoord2f(0.0f, 0.0f);
  981.                     glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  982.                     glTexCoord2f(1.0f, 0.0f);
  983.                     glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  984.                 }
  985.             }
  986.         }
  987.     glEnd();
  988.  
  989. }
  990.  
  991. void rendertanks(void)
  992. {
  993.     int i, x, y;
  994.  
  995.     for(i=0; i<2; i++)
  996.     {
  997.         glEnable(GL_TEXTURE_2D);
  998.         if(i==0)
  999.             glBindTexture(GL_TEXTURE_2D, texture[REDTANK_TEXTURE]);
  1000.         if(i==1)
  1001.             glBindTexture(GL_TEXTURE_2D, texture[BLUETANK_TEXTURE]);
  1002.         glTranslatef(player[i].pos.x, player[i].pos.y, (float)(heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)+1]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)+1])/(float)4);
  1003.         glTranslatef(0, 0, -((float)player[i].rebirth/(float)10));
  1004.         glRotatef((float)player[i].rot, 0, 0, 1);
  1005.         glCallList(model[TANK_MODEL]);
  1006.         glDisable(GL_TEXTURE_2D);
  1007.         if(player[i].mode==MISSLE_MODE && player[i].rebirth==0)
  1008.         {
  1009.             glDisable(GL_DEPTH_TEST);
  1010.             glEnable(GL_BLEND);
  1011.             glBegin(GL_QUADS);
  1012.                 if(player[i].missleload==0)
  1013.                     glColor4f(0.3f, 1.0f, 0.0f, 0.2f);
  1014.                 else
  1015.                     glColor4f(0.8f, 0.8f, 0.0f, 0.2f);
  1016.                 glVertex3f(33, -0.5f, 5);
  1017.                 glVertex3f(27, -0.5f, 5);
  1018.                 glVertex3f(27, 0.5f, 5);
  1019.                 glVertex3f(33, 0.5f, 5);
  1020.                 glVertex3f(30.5f, -3, 5);
  1021.                 glVertex3f(29.5f, -3, 5);
  1022.                 glVertex3f(29.5f, 3, 5);
  1023.                 glVertex3f(30.5f, 3, 5);
  1024.             glEnd();
  1025.             glEnable(GL_DEPTH_TEST);
  1026.             glRotatef((float)-player[i].rot, 0, 0, 1);
  1027.             glTranslatef(0, 0, (float)player[i].rebirth/(float)10);
  1028.             glTranslatef(-player[i].pos.x, -player[i].pos.y, -((float)(heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)+1]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)+1])/(float)4));
  1029.             glEnable(GL_TEXTURE_2D);
  1030.             for((int)(player[i].pos.y/10)>=0 ? y=(int)(player[i].pos.y/10)-1 : y=0; y<(int)(player[i].pos.y/10)+2 && y<20; y++)
  1031.                 for((int)(player[i].pos.x/10)>=0 ? x=(int)(player[i].pos.x/10)-1 : x=0; x<(int)(player[i].pos.x/10)+2 && x<30; x++)
  1032.                 {
  1033.                     if(grid[x][y]==BRICK1)
  1034.                         glBindTexture(GL_TEXTURE_2D, texture[BRICK1_TEXTURE]);
  1035.                     else if(grid[x][y]==BRICK0)
  1036.                         glBindTexture(GL_TEXTURE_2D, texture[BRICK0_TEXTURE]);
  1037.                     else
  1038.                         continue;
  1039.                     glBegin(GL_QUADS);
  1040.                         // Back Face:
  1041.                         glColor4f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 1.0f);
  1042.                         glTexCoord2f(1.0f, 1.0f);
  1043.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  1044.                         glTexCoord2f(0.0f, 1.0f);
  1045.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  1046.                         glTexCoord2f(0.0f, 0.0f);
  1047.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x][y+1]);
  1048.                         glTexCoord2f(1.0f, 0.0f);
  1049.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x+1][y+1]);
  1050.                         // Front Face:
  1051.                         glColor4f(0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 0.2f+brightmap[x][y], 1.0f);
  1052.                         glTexCoord2f(1.0f, 1.0f);
  1053.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  1054.                         glTexCoord2f(0.0f, 1.0f);
  1055.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  1056.                         glTexCoord2f(0.0f, 0.0f);
  1057.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  1058.                         glTexCoord2f(1.0f, 0.0f);
  1059.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  1060.                         // Left Face:
  1061.                         glColor4f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 1.0f);
  1062.                         glTexCoord2f(1.0f, 1.0f);
  1063.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  1064.                         glTexCoord2f(0.0f, 1.0f);
  1065.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  1066.                         glTexCoord2f(0.0f, 0.0f);
  1067.                         glVertex3f((float)(x*10), (float)(y*10), (float)heightmap[x][y]);
  1068.                         glTexCoord2f(1.0f, 0.0f);
  1069.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)heightmap[x][y+1]);
  1070.                         // Right Face:
  1071.                         glColor4f(0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 0.1f+brightmap[x][y], 1.0f);
  1072.                         glTexCoord2f(1.0f, 1.0f);
  1073.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  1074.                         glTexCoord2f(0.0f, 1.0f);
  1075.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  1076.                         glTexCoord2f(0.0f, 0.0f);
  1077.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)heightmap[x+1][y+1]);
  1078.                         glTexCoord2f(1.0f, 0.0f);
  1079.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)heightmap[x+1][y]);
  1080.                         // Top Face:
  1081.                         glColor4f(0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 0.4f+brightmap[x][y], 1.0f);
  1082.                         glTexCoord2f(1.0f, 1.0f);
  1083.                         glVertex3f((float)(x*10+10), (float)(y*10), (float)10);
  1084.                         glTexCoord2f(0.0f, 1.0f);
  1085.                         glVertex3f((float)(x*10), (float)(y*10), (float)10);
  1086.                         glTexCoord2f(0.0f, 0.0f);
  1087.                         glVertex3f((float)(x*10), (float)(y*10+10), (float)10);
  1088.                         glTexCoord2f(1.0f, 0.0f);
  1089.                         glVertex3f((float)(x*10+10), (float)(y*10+10), (float)10);
  1090.                     glEnd();
  1091.                 }
  1092.             glTranslatef(0, 0, (float)player[i].rebirth/(float)10);
  1093.             glTranslatef(player[i].pos.x, player[i].pos.y, (float)(heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)+1]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)+1])/(float)4);
  1094.             glRotatef((float)player[i].rot, 0, 0, 1);
  1095.             glDisable(GL_TEXTURE_2D);
  1096.             glDisable(GL_BLEND);
  1097.         }
  1098.         glRotatef((float)-player[i].rot, 0, 0, 1);
  1099.         glTranslatef(0, 0, (float)player[i].rebirth/(float)10);
  1100.         glTranslatef(-player[i].pos.x, -player[i].pos.y, -((float)(heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)]+heightmap[(int)(player[i].pos.x/10)][(int)(player[i].pos.y/10)+1]+heightmap[(int)(player[i].pos.x/10)+1][(int)(player[i].pos.y/10)+1])/(float)4));
  1101.         if(player[i].mode==GRENADE_MODE && player[i].rebirth==0)
  1102.         {
  1103.             if(player[i].buildpos.x>=0 && player[i].buildpos.x<30 && player[i].buildpos.y>=0 && player[i].buildpos.y <20)
  1104.             {
  1105.                 glDisable(GL_DEPTH_TEST);
  1106.                 glEnable(GL_BLEND);
  1107.                 glBegin(GL_LINES);
  1108.                     if(grid[player[i].buildpos.x][player[i].buildpos.y]==EMPTY)
  1109.                         if(player[i].grenadeload==0)
  1110.                             glColor4f(0.3f, 1.0f, 0.0f, 0.2f);
  1111.                         else
  1112.                             glColor4f(0.8f, 0.8f, 0.0f, 0.2f);
  1113.                     else
  1114.                         glColor4f(1.0f, 0.3f, 0.0f, 0.2f);
  1115.                     glVertex3f((float)player[i].buildpos.x*10+5, (float)player[i].buildpos.y*10+5, 10.0f);
  1116.                     glVertex3f((float)player[i].buildpos.x*10+5, (float)player[i].buildpos.y*10+5, 0.0f);
  1117.                     glVertex3f((float)player[i].buildpos.x*10, (float)player[i].buildpos.y*10+5, 5.0f);
  1118.                     glVertex3f((float)player[i].buildpos.x*10+10, (float)player[i].buildpos.y*10+5, 5.0f);
  1119.                     glVertex3f((float)player[i].buildpos.x*10+5, (float)player[i].buildpos.y*10, 5.0f);
  1120.                     glVertex3f((float)player[i].buildpos.x*10+5, (float)player[i].buildpos.y*10+10, 5.0f);
  1121.                 glEnd();
  1122.                 glDisable(GL_BLEND);
  1123.                 glEnable(GL_DEPTH_TEST);
  1124.             }
  1125.         }
  1126.     }
  1127.     glEnable(GL_TEXTURE_2D);
  1128. }
  1129.  
  1130. void rendermissles(void)
  1131. {
  1132.     int i;
  1133.     glBindTexture(GL_TEXTURE_2D, texture[MISSLE_TEXTURE]);
  1134.  
  1135.     for(i=0; i<20; i++)
  1136.     {
  1137.         if(missle[i].active)
  1138.         {
  1139.             glTranslatef(missle[i].pos.x, missle[i].pos.y, (float)0);
  1140.             glRotatef((float)missle[i].rot, 0, 0, 1);
  1141.             glBegin(GL_TRIANGLES);
  1142.                 glColor3f(1.0f, 1.0f, 1.0f);
  1143.                 glTexCoord2f(0.5f, 1.0f);
  1144.                 glVertex3f(3, 0, 8);
  1145.                 glTexCoord2f(0.0f, 0.0f);
  1146.                 glVertex3f(-3, -2, 8);
  1147.                 glTexCoord2f(1.0f, 0.0f);
  1148.                 glVertex3f(-3, 2, 8);
  1149.             glEnd();
  1150.             glRotatef((float)-missle[i].rot, 0, 0, 1);
  1151.             glTranslatef(-missle[i].pos.x, -missle[i].pos.y, (float)0);
  1152.         }
  1153.     }
  1154. }
  1155.  
  1156. void rendersmoke(void)
  1157. {
  1158.     int i;
  1159.     glEnable(GL_BLEND);
  1160.     glBindTexture(GL_TEXTURE_2D, texture[SMOKE_TEXTURE]);
  1161.  
  1162.     for(i=0; i<50; i++)
  1163.     {
  1164.         if(smoke[i].active)
  1165.         {
  1166.             glTranslatef(smoke[i].pos.x, smoke[i].pos.y, (float)0);
  1167.             glRotatef((float)smoke[i].rot, 0, 0, 1);
  1168.             glBegin(GL_QUADS);
  1169.                 glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
  1170.                 glTexCoord2f(1.0f, 1.0f);
  1171.                 glVertex3f(0, 3, 8);
  1172.                 glTexCoord2f(0.0f, 1.0f);
  1173.                 glVertex3f(0, -3, 8);
  1174.                 glTexCoord2f(0.0f, 1.0f-(float)smoke[i].length/(float)36);
  1175.                 glVertex3f(-(float)smoke[i].length, -4, 8);
  1176.                 glTexCoord2f(1.0f, 1.0f-(float)smoke[i].length/(float)36);
  1177.                 glVertex3f(-(float)smoke[i].length, 4, 8);
  1178.             glEnd();
  1179.             glRotatef((float)-smoke[i].rot, 0, 0, 1);
  1180.             glTranslatef(-smoke[i].pos.x, -smoke[i].pos.y, (float)0);
  1181.  
  1182.             if(smoke[i].stillmoving)
  1183.             {
  1184.                 smoke[i].pos.x+=(float)cos(smoke[i].rot*PI/180)*4;
  1185.                 smoke[i].pos.y+=(float)sin(smoke[i].rot*PI/180)*4;
  1186.             }
  1187.  
  1188.             smoke[i].life++;
  1189.             if(smoke[i].stillmoving && smoke[i].life<10)
  1190.                 smoke[i].length+=4;
  1191.  
  1192.             if(smoke[i].stillmoving==0)
  1193.             {
  1194.                 smoke[i].length-=4;
  1195.                 if(smoke[i].length<=0)
  1196.                 {
  1197.                     smoke[i].active=0;
  1198.                     if(i<nextsmokeslot)
  1199.                         nextsmokeslot=i;
  1200.                 }
  1201.             }
  1202.         }
  1203.     }
  1204.     glDisable(GL_BLEND);
  1205. }
  1206.  
  1207. void rendergrenades(void)
  1208. {
  1209.     int i;
  1210.     glDisable(GL_TEXTURE_2D);
  1211.  
  1212.     for(i=0; i<20; i++)
  1213.     {
  1214.         if(grenade[i].stage>0)
  1215.         {
  1216.             glBegin(GL_QUADS);
  1217.                 glColor3f(0.0f, 0.2f, 0.0f);
  1218.                 glVertex3f((float)(grenade[i].pos.x*10+8), (float)(grenade[i].pos.y*10+2), (float)(heightmap[grenade[i].pos.x][grenade[i].pos.y]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y]+heightmap[grenade[i].pos.x][grenade[i].pos.y+1]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y+1])/(float)4+(float)grenade[i].stage/(float)3);
  1219.                 glVertex3f((float)(grenade[i].pos.x*10+2), (float)(grenade[i].pos.y*10+2), (float)(heightmap[grenade[i].pos.x][grenade[i].pos.y]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y]+heightmap[grenade[i].pos.x][grenade[i].pos.y+1]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y+1])/(float)4+(float)grenade[i].stage/(float)3);
  1220.                 glVertex3f((float)(grenade[i].pos.x*10+2), (float)(grenade[i].pos.y*10+8), (float)(heightmap[grenade[i].pos.x][grenade[i].pos.y]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y]+heightmap[grenade[i].pos.x][grenade[i].pos.y+1]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y+1])/(float)4+(float)grenade[i].stage/(float)3);
  1221.                 glVertex3f((float)(grenade[i].pos.x*10+8), (float)(grenade[i].pos.y*10+8), (float)(heightmap[grenade[i].pos.x][grenade[i].pos.y]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y]+heightmap[grenade[i].pos.x][grenade[i].pos.y+1]+heightmap[grenade[i].pos.x+1][grenade[i].pos.y+1])/(float)4+(float)grenade[i].stage/(float)3);
  1222.             glEnd();
  1223.             grenade[i].stage--;
  1224.  
  1225.             if(grenade[i].stage==0)
  1226.             {
  1227.                 if(i<nextgrenadeslot)
  1228.                     nextgrenadeslot=i;
  1229.                 createbigexplosion(grenade[i].pos.x, grenade[i].pos.y);
  1230.             }
  1231.         }
  1232.     }
  1233. }
  1234.  
  1235. void renderexplosions(void)
  1236. {
  1237.     int i;
  1238.     glDisable(GL_TEXTURE_2D);
  1239.     glEnable(GL_BLEND);
  1240.  
  1241.     for(i=0; i<50; i++)
  1242.     {
  1243.         if(explosion[i].stage>0)
  1244.         {
  1245.             glTranslatef((float)(explosion[i].pos.x)*10+5, (float)(explosion[i].pos.y)*10+5, 0);
  1246.             glScalef(20, 20, (float)(20-explosion[i].stage));
  1247.             glBegin(GL_TRIANGLES);
  1248.                 glColor4f((float)0.886, (float)0.5316, (float)0, (float)explosion[i].stage/(float)20);
  1249.                 glVertex3f((float)-0.1, (float)0.173205, (float)0.2); glVertex3f((float)-0.5, (float)0, (float)0); glVertex3f((float)-0.25, (float)0.433013, (float)0);
  1250.                 glColor4f((float)0.8045, (float)0.4827, (float)0, (float)explosion[i].stage/(float)20);
  1251.                 glVertex3f((float)-0.1, (float)0.173205, (float)0.2); glVertex3f((float)-0.2, (float)0, (float)0.2); glVertex3f((float)-0.5, (float)0, (float)0);
  1252.                 glColor4f((float)0.681, (float)0.4086, (float)0, (float)explosion[i].stage/(float)20);
  1253.                 glVertex3f((float)-0.075, (float)0.129904, (float)0.4); glVertex3f((float)-0.2, (float)0, (float)0.2); glVertex3f((float)-0.1, (float)0.173205, (float)0.2);
  1254.                 glColor4f((float)0.9745, (float)0.5847, (float)0, (float)explosion[i].stage/(float)20);
  1255.                 glVertex3f((float)-0.075, (float)0.129904, (float)0.4); glVertex3f((float)-0.15, (float)0, (float)0.4); glVertex3f((float)-0.2, (float)0, (float)0.2);
  1256.                 glColor4f((float)0.864, (float)0.5184, (float)0, (float)explosion[i].stage/(float)20);
  1257.                 glVertex3f((float)-0.4, (float)0, (float)0.7); glVertex3f((float)-0.15, (float)0, (float)0.4); glVertex3f((float)-0.075, (float)0.129904, (float)0.4);
  1258.                 glColor4f((float)0.6775, (float)0.4065, (float)0, (float)explosion[i].stage/(float)20);
  1259.                 glVertex3f((float)-0.2, (float)0.34641, (float)0.7); glVertex3f((float)-0.4, (float)0, (float)0.7); glVertex3f((float)-0.075, (float)0.129904, (float)0.4);
  1260.                 glColor4f((float)0.5455, (float)0.3273, (float)0, (float)explosion[i].stage/(float)20);
  1261.                 glVertex3f((float)-0.15, (float)0.259808, (float)0.9); glVertex3f((float)-0.4, (float)0, (float)0.7); glVertex3f((float)-0.2, (float)0.34641, (float)0.7);
  1262.                 glColor4f((float)0.8505, (float)0.5103, (float)0, (float)explosion[i].stage/(float)20);
  1263.                 glVertex3f((float)-0.15, (float)0.259808, (float)0.9); glVertex3f((float)-0.3, (float)0, (float)0.9); glVertex3f((float)-0.4, (float)0, (float)0.7);
  1264.                 glColor4f((float)0.8585, (float)0.5151, (float)0, (float)explosion[i].stage/(float)20);
  1265.                 glVertex3f((float)0, (float)0, (float)1); glVertex3f((float)-0.3, (float)0, (float)0.9); glVertex3f((float)-0.15, (float)0.259808, (float)0.9);
  1266.                 glColor4f((float)0.755, (float)0.453, (float)0, (float)explosion[i].stage/(float)20);
  1267.                 glVertex3f((float)0.25, (float)0.433013, (float)0); glVertex3f((float)-0.1, (float)0.173205, (float)0.2); glVertex3f((float)-0.25, (float)0.433013, (float)0);
  1268.                 glColor4f((float)0.538, (float)0.3228, (float)0, (float)explosion[i].stage/(float)20);
  1269.                 glVertex3f((float)0.1, (float)0.173205, (float)0.2); glVertex3f((float)-0.1, (float)0.173205, (float)0.2); glVertex3f((float)0.25, (float)0.433013, (float)0);
  1270.                 glColor4f((float)0.6235, (float)0.3741, (float)0, (float)explosion[i].stage/(float)20);
  1271.                 glVertex3f((float)0.1, (float)0.173205, (float)0.2); glVertex3f((float)-0.075, (float)0.129904, (float)0.4); glVertex3f((float)-0.1, (float)0.173205, (float)0.2);
  1272.                 glColor4f((float)0.8815, (float)0.5289, (float)0, (float)explosion[i].stage/(float)20);
  1273.                 glVertex3f((float)0.075, (float)0.129904, (float)0.4); glVertex3f((float)-0.075, (float)0.129904, (float)0.4); glVertex3f((float)0.1, (float)0.173205, (float)0.2);
  1274.                 glColor4f((float)0.566, (float)0.3396, (float)0, (float)explosion[i].stage/(float)20);
  1275.                 glVertex3f((float)0.075, (float)0.129904, (float)0.4); glVertex3f((float)-0.2, (float)0.34641, (float)0.7); glVertex3f((float)-0.075, (float)0.129904, (float)0.4);
  1276.                 glColor4f((float)0.8875, (float)0.5325, (float)0, (float)explosion[i].stage/(float)20);
  1277.                 glVertex3f((float)0.2, (float)0.34641, (float)0.7); glVertex3f((float)-0.2, (float)0.34641, (float)0.7); glVertex3f((float)0.075, (float)0.129904, (float)0.4);
  1278.                 glColor4f((float)0.969, (float)0.5814, (float)0, (float)explosion[i].stage/(float)20);
  1279.                 glVertex3f((float)0.2, (float)0.34641, (float)0.7); glVertex3f((float)-0.15, (float)0.259808, (float)0.9); glVertex3f((float)-0.2, (float)0.34641, (float)0.7);
  1280.                 glColor4f((float)0.5375, (float)0.3225, (float)0, (float)explosion[i].stage/(float)20);
  1281.                 glVertex3f((float)0.15, (float)0.259808, (float)0.9); glVertex3f((float)-0.15, (float)0.259808, (float)0.9); glVertex3f((float)0.2, (float)0.34641, (float)0.7);
  1282.                 glColor4f((float)0.5395, (float)0.3237, (float)0, (float)explosion[i].stage/(float)20);
  1283.                 glVertex3f((float)0.15, (float)0.259808, (float)0.9); glVertex3f((float)0, (float)0, (float)1); glVertex3f((float)-0.15, (float)0.259808, (float)0.9);
  1284.                 glColor4f((float)0.8795, (float)0.5277, (float)0, (float)explosion[i].stage/(float)20);
  1285.                 glVertex3f((float)0.2, (float)-0, (float)0.2); glVertex3f((float)0.1, (float)0.173205, (float)0.2); glVertex3f((float)0.25, (float)0.433013, (float)0);
  1286.                 glColor4f((float)0.536, (float)0.3216, (float)0, (float)explosion[i].stage/(float)20);
  1287.                 glVertex3f((float)0.5, (float)-0, (float)0); glVertex3f((float)0.2, (float)-0, (float)0.2); glVertex3f((float)0.25, (float)0.433013, (float)0);
  1288.                 glColor4f((float)0.841, (float)0.5046, (float)0, (float)explosion[i].stage/(float)20);
  1289.                 glVertex3f((float)0.2, (float)-0, (float)0.2); glVertex3f((float)0.075, (float)0.129904, (float)0.4); glVertex3f((float)0.1, (float)0.173205, (float)0.2);
  1290.                 glColor4f((float)0.92, (float)0.552, (float)0, (float)explosion[i].stage/(float)20);
  1291.                 glVertex3f((float)0.15, (float)-0, (float)0.4); glVertex3f((float)0.075, (float)0.129904, (float)0.4); glVertex3f((float)0.2, (float)-0, (float)0.2);
  1292.                 glColor4f((float)0.755, (float)0.453, (float)0, (float)explosion[i].stage/(float)20);
  1293.                 glVertex3f((float)0.4, (float)-0, (float)0.7); glVertex3f((float)0.2, (float)0.34641, (float)0.7); glVertex3f((float)0.075, (float)0.129904, (float)0.4);
  1294.                 glColor4f((float)0.681, (float)0.4086, (float)0, (float)explosion[i].stage/(float)20);
  1295.                 glVertex3f((float)0.15, (float)-0, (float)0.4); glVertex3f((float)0.4, (float)-0, (float)0.7); glVertex3f((float)0.075, (float)0.129904, (float)0.4);
  1296.                 glColor4f((float)0.798, (float)0.4788, (float)0, (float)explosion[i].stage/(float)20);
  1297.                 glVertex3f((float)0.4, (float)-0, (float)0.7); glVertex3f((float)0.15, (float)0.259808, (float)0.9); glVertex3f((float)0.2, (float)0.34641, (float)0.7);
  1298.                 glColor4f((float)0.9065, (float)0.5439, (float)0, (float)explosion[i].stage/(float)20);
  1299.                 glVertex3f((float)0.3, (float)-0, (float)0.9); glVertex3f((float)0.15, (float)0.259808, (float)0.9); glVertex3f((float)0.4, (float)-0, (float)0.7);
  1300.                 glColor4f((float)0.953, (float)0.5718, (float)0, (float)explosion[i].stage/(float)20);
  1301.                 glVertex3f((float)0.3, (float)-0, (float)0.9); glVertex3f((float)0, (float)0, (float)1); glVertex3f((float)0.15, (float)0.259808, (float)0.9);
  1302.                 glColor4f((float)0.6565, (float)0.3939, (float)0, (float)explosion[i].stage/(float)20);
  1303.                 glVertex3f((float)0.25, (float)-0.433013, (float)0); glVertex3f((float)0.2, (float)-0, (float)0.2); glVertex3f((float)0.5, (float)-0, (float)0);
  1304.                 glColor4f((float)0.7415, (float)0.4449, (float)0, (float)explosion[i].stage/(float)20);
  1305.                 glVertex3f((float)0.1, (float)-0.173205, (float)0.2); glVertex3f((float)0.2, (float)-0, (float)0.2); glVertex3f((float)0.25, (float)-0.433013, (float)0);
  1306.                 glColor4f((float)0.975, (float)0.585, (float)0, (float)explosion[i].stage/(float)20);
  1307.                 glVertex3f((float)0.075, (float)-0.129904, (float)0.4); glVertex3f((float)0.15, (float)-0, (float)0.4); glVertex3f((float)0.2, (float)-0, (float)0.2);
  1308.                 glColor4f((float)0.877, (float)0.5262, (float)0, (float)explosion[i].stage/(float)20);
  1309.                 glVertex3f((float)0.1, (float)-0.173205, (float)0.2); glVertex3f((float)0.075, (float)-0.129904, (float)0.4); glVertex3f((float)0.2, (float)-0, (float)0.2);
  1310.                 glColor4f((float)0.949, (float)0.5694, (float)0, (float)explosion[i].stage/(float)20);
  1311.                 glVertex3f((float)0.075, (float)-0.129904, (float)0.4); glVertex3f((float)0.4, (float)-0, (float)0.7); glVertex3f((float)0.15, (float)-0, (float)0.4);
  1312.                 glColor4f((float)0.7815, (float)0.4689, (float)0, (float)explosion[i].stage/(float)20);
  1313.                 glVertex3f((float)0.2, (float)-0.34641, (float)0.7); glVertex3f((float)0.4, (float)-0, (float)0.7); glVertex3f((float)0.075, (float)-0.129904, (float)0.4);
  1314.                 glColor4f((float)0.751, (float)0.4506, (float)0, (float)explosion[i].stage/(float)20);
  1315.                 glVertex3f((float)0.15, (float)-0.259808, (float)0.9); glVertex3f((float)0.3, (float)-0, (float)0.9); glVertex3f((float)0.4, (float)-0, (float)0.7);
  1316.                 glColor4f((float)0.8635, (float)0.5181, (float)0, (float)explosion[i].stage/(float)20);
  1317.                 glVertex3f((float)0.2, (float)-0.34641, (float)0.7); glVertex3f((float)0.15, (float)-0.259808, (float)0.9); glVertex3f((float)0.4, (float)-0, (float)0.7);
  1318.                 glColor4f((float)0.777, (float)0.4662, (float)0, (float)explosion[i].stage/(float)20);
  1319.                 glVertex3f((float)0.15, (float)-0.259808, (float)0.9); glVertex3f((float)0, (float)0, (float)1); glVertex3f((float)0.3, (float)-0, (float)0.9);
  1320.                 glColor4f((float)0.695, (float)0.417, (float)0, (float)explosion[i].stage/(float)20);
  1321.                 glVertex3f((float)0.1, (float)-0.173205, (float)0.2); glVertex3f((float)0.25, (float)-0.433013, (float)0); glVertex3f((float)-0.25, (float)-0.433013, (float)0);
  1322.                 glColor4f((float)0.953, (float)0.5718, (float)0, (float)explosion[i].stage/(float)20);
  1323.                 glVertex3f((float)-0.1, (float)-0.173205, (float)0.2); glVertex3f((float)0.1, (float)-0.173205, (float)0.2); glVertex3f((float)-0.25, (float)-0.433013, (float)0);
  1324.                 glColor4f((float)0.969, (float)0.5814, (float)0, (float)explosion[i].stage/(float)20);
  1325.                 glVertex3f((float)-0.075, (float)-0.129904, (float)0.4); glVertex3f((float)0.1, (float)-0.173205, (float)0.2); glVertex3f((float)-0.1, (float)-0.173205, (float)0.2);
  1326.                 glColor4f((float)0.9145, (float)0.5487, (float)0, (float)explosion[i].stage/(float)20);
  1327.                 glVertex3f((float)-0.075, (float)-0.129904, (float)0.4); glVertex3f((float)0.075, (float)-0.129904, (float)0.4); glVertex3f((float)0.1, (float)-0.173205, (float)0.2);
  1328.                 glColor4f((float)0.577, (float)0.3462, (float)0, (float)explosion[i].stage/(float)20);
  1329.                 glVertex3f((float)0.2, (float)-0.34641, (float)0.7); glVertex3f((float)0.075, (float)-0.129904, (float)0.4); glVertex3f((float)-0.075, (float)-0.129904, (float)0.4);
  1330.                 glColor4f((float)0.8955, (float)0.5373, (float)0, (float)explosion[i].stage/(float)20);
  1331.                 glVertex3f((float)-0.2, (float)-0.34641, (float)0.7); glVertex3f((float)0.2, (float)-0.34641, (float)0.7); glVertex3f((float)-0.075, (float)-0.129904, (float)0.4);
  1332.                 glColor4f((float)0.8345, (float)0.5007, (float)0, (float)explosion[i].stage/(float)20);
  1333.                 glVertex3f((float)-0.15, (float)-0.259808, (float)0.9); glVertex3f((float)0.2, (float)-0.34641, (float)0.7); glVertex3f((float)-0.2, (float)-0.34641, (float)0.7);
  1334.                 glColor4f((float)0.8905, (float)0.5343, (float)0, (float)explosion[i].stage/(float)20);
  1335.                 glVertex3f((float)-0.15, (float)-0.259808, (float)0.9); glVertex3f((float)0.15, (float)-0.259808, (float)0.9); glVertex3f((float)0.2, (float)-0.34641, (float)0.7);
  1336.                 glColor4f((float)0.731, (float)0.4386, (float)0, (float)explosion[i].stage/(float)20);
  1337.                 glVertex3f((float)0, (float)0, (float)1); glVertex3f((float)0.15, (float)-0.259808, (float)0.9); glVertex3f((float)-0.15, (float)-0.259808, (float)0.9);
  1338.                 glColor4f((float)0.753, (float)0.4518, (float)0, (float)explosion[i].stage/(float)20);
  1339.                 glVertex3f((float)-0.2, (float)0, (float)0.2); glVertex3f((float)-0.25, (float)-0.433013, (float)0); glVertex3f((float)-0.5, (float)0, (float)0);
  1340.                 glColor4f((float)0.579, (float)0.3474, (float)0, (float)explosion[i].stage/(float)20);
  1341.                 glVertex3f((float)-0.2, (float)0, (float)0.2); glVertex3f((float)-0.1, (float)-0.173205, (float)0.2); glVertex3f((float)-0.25, (float)-0.433013, (float)0);
  1342.                 glColor4f((float)0.9225, (float)0.5535, (float)0, (float)explosion[i].stage/(float)20);
  1343.                 glVertex3f((float)-0.075, (float)-0.129904, (float)0.4); glVertex3f((float)-0.1, (float)-0.173205, (float)0.2); glVertex3f((float)-0.2, (float)0, (float)0.2);
  1344.                 glColor4f((float)0.5835, (float)0.3501, (float)0, (float)explosion[i].stage/(float)20);
  1345.                 glVertex3f((float)-0.15, (float)0, (float)0.4); glVertex3f((float)-0.075, (float)-0.129904, (float)0.4); glVertex3f((float)-0.2, (float)0, (float)0.2);
  1346.                 glColor4f((float)0.6135, (float)0.3681, (float)0, (float)explosion[i].stage/(float)20);
  1347.                 glVertex3f((float)-0.4, (float)0, (float)0.7); glVertex3f((float)-0.075, (float)-0.129904, (float)0.4); glVertex3f((float)-0.15, (float)0, (float)0.4);
  1348.                 glColor4f((float)0.8195, (float)0.4917, (float)0, (float)explosion[i].stage/(float)20);
  1349.                 glVertex3f((float)-0.4, (float)0, (float)0.7); glVertex3f((float)-0.2, (float)-0.34641, (float)0.7); glVertex3f((float)-0.075, (float)-0.129904, (float)0.4);
  1350.                 glColor4f((float)0.783, (float)0.4698, (float)0, (float)explosion[i].stage/(float)20);
  1351.                 glVertex3f((float)-0.15, (float)-0.259808, (float)0.9); glVertex3f((float)-0.2, (float)-0.34641, (float)0.7); glVertex3f((float)-0.4, (float)0, (float)0.7);
  1352.                 glColor4f((float)0.84, (float)0.504, (float)0, (float)explosion[i].stage/(float)20);
  1353.                 glVertex3f((float)-0.3, (float)0, (float)0.9); glVertex3f((float)-0.15, (float)-0.259808, (float)0.9); glVertex3f((float)-0.4, (float)0, (float)0.7);
  1354.                 glColor4f((float)0.549, (float)0.3294, (float)0, (float)explosion[i].stage/(float)20);
  1355.                 glVertex3f((float)0, (float)0, (float)1); glVertex3f((float)-0.15, (float)-0.259808, (float)0.9); glVertex3f((float)-0.3, (float)0, (float)0.9);
  1356.             glEnd();
  1357.             glScalef((float)1/(float)20, (float)1/(float)20, (float)1/(float)(20-explosion[i].stage));
  1358.             glTranslatef(-(float)(explosion[i].pos.x*10+5), -(float)(explosion[i].pos.y*10+5), 0);
  1359.             explosion[i].stage--;
  1360.             if(explosion[i].stage==0 && i<nextexplosionslot)
  1361.                 nextexplosionslot=i;
  1362.         }
  1363.     }
  1364.     glDisable(GL_BLEND);
  1365.     glEnable(GL_TEXTURE_2D);
  1366. }
  1367.  
  1368. void renderparticles(void)
  1369. {
  1370.     int i;
  1371.     glEnable(GL_BLEND);
  1372.     glDisable(GL_TEXTURE_2D);
  1373.     glBegin(GL_POINTS);
  1374.         for(i=0; i<500; i++)
  1375.         {
  1376.             if(particle[i].life>0)
  1377.             {
  1378.                 glColor4f(1.0f, 0.7f, 0.0f, ((float)70-(float)particle[i].life)/(float)70);
  1379.                 glVertex3f(particle[i].pos.x, particle[i].pos.y, particle[i].pos.z);
  1380.                 particle[i].pos.x+=particle[i].dir.x;
  1381.                 particle[i].pos.y+=particle[i].dir.y;
  1382.                 particle[i].pos.z+=particle[i].dir.z;
  1383.                 particle[i].dir.z-=0.03f;
  1384.                 particle[i].life++;
  1385.                 if(particle[i].pos.z<0)
  1386.                 {
  1387.                     particle[i].life=0;
  1388.                     if(i<nextparticleslot)
  1389.                         nextparticleslot=i;
  1390.                 }
  1391.             }
  1392.         }
  1393.     glEnd();
  1394.     glDisable(GL_BLEND);
  1395. }
  1396. void renderdebris(void)
  1397. {
  1398.     int i;
  1399.     glEnable(GL_TEXTURE_2D);
  1400.     glBindTexture(GL_TEXTURE_2D, texture[DEBRIS_TEXTURE]);
  1401.     glBegin(GL_QUADS);
  1402.         for(i=0; i<100; i++)
  1403.         {
  1404.             if(debris[i].active==1)
  1405.             {
  1406.                 glColor3f(debris[i].color.x, debris[i].color.y, debris[i].color.z);
  1407.  
  1408.                 glTexCoord2f(1.0f, 1.0f);
  1409.                 glVertex3f(debris[i].pos.x+5, debris[i].pos.y-(float)cos(cameraangle*PI/180)*5, debris[i].pos.z+(float)sin(cameraangle*PI/180)*5);
  1410.                 glTexCoord2f(0.0f, 1.0f);
  1411.                 glVertex3f(debris[i].pos.x, debris[i].pos.y-(float)cos(cameraangle*PI/180)*5, debris[i].pos.z+(float)sin(cameraangle*PI/180)*5);
  1412.                 glTexCoord2f(0.0f, 0.0f);
  1413.                 glVertex3f(debris[i].pos.x, debris[i].pos.y, debris[i].pos.z);
  1414.                 glTexCoord2f(1.0f, 0.0f);
  1415.                 glVertex3f(debris[i].pos.x+5, debris[i].pos.y, debris[i].pos.z);
  1416.  
  1417.                 debris[i].pos.x+=debris[i].dir.x;
  1418.                 debris[i].pos.y+=debris[i].dir.y;
  1419.                 debris[i].pos.z+=debris[i].dir.z;
  1420.                 debris[i].dir.z-=0.03f;
  1421.                 if(debris[i].pos.z<0)
  1422.                 {
  1423.                     debris[i].active=0;
  1424.                     if(i<nextdebrisslot)
  1425.                         nextdebrisslot=i;
  1426.                 }
  1427.             }
  1428.         }
  1429.     glEnd();
  1430. }
  1431.  
  1432. void renderfog(void)
  1433. {
  1434.     float i;
  1435.     if(fogenabled)
  1436.     {
  1437.         glEnable(GL_BLEND);
  1438.         glDisable(GL_TEXTURE_2D);
  1439.         glBegin(GL_TRIANGLES);
  1440.         for(i=2.0f; i<=12; i+=2.0f)
  1441.         {
  1442.             glColor4f(1.0f, 1.0f, 1.0f, 0.1f);
  1443.             glVertex3f(300.0f, 0.0f, i);
  1444.             glVertex3f(0.0f, 0.0f, i);
  1445.             glVertex3f(0.0f, 200.0f, i);
  1446.  
  1447.             glVertex3f(0.0f, 200.0f, i);
  1448.             glVertex3f(300.0f, 200.0f, i);
  1449.             glVertex3f(300.0f, 0.0f, i);
  1450.         }
  1451.         glEnd();
  1452.         glEnable(GL_TEXTURE_2D);
  1453.         glDisable(GL_BLEND);
  1454.     }
  1455. }
  1456.  
  1457. void renderrain(void)
  1458. {
  1459.     int i;
  1460.     glDisable(GL_TEXTURE_2D);
  1461.     glEnable(GL_BLEND);
  1462.     glBegin(GL_LINES);
  1463.         for(i=0; i<raindensity; i++)
  1464.         {
  1465.             glColor4f(0.0f, 0.5f, 1.0f, 0.6f);
  1466.             glVertex3f(rain[i].pos.x, rain[i].pos.y, rain[i].pos.z);
  1467.             glColor4f(0.0f, 0.0f, 0.2f, 0.2f);
  1468.             glVertex3f(rain[i].pos.x, rain[i].pos.y, rain[i].pos.z+5);
  1469.  
  1470.             rain[i].pos.z-=4.0f;
  1471.             if(rain[i].pos.z<0)
  1472.             {
  1473.                 rain[i].pos.x=(float)(rand()%300);
  1474.                 rain[i].pos.y=(float)(rand()%200);
  1475.                 rain[i].pos.z=100.0f;
  1476.             }
  1477.         }
  1478.     glEnd();
  1479. }
  1480.  
  1481. void renderwall(void)
  1482. {
  1483.     glBindTexture(GL_TEXTURE_2D, texture[WALL_TEXTURE]);
  1484.     glBegin(GL_QUADS);
  1485.         if(wall<15 && wall>0)
  1486.         {
  1487.             if(timeofday==0)
  1488.                 glColor3f(0.9f, 0.9f, 0.9f);
  1489.             else
  1490.                 glColor3f(0.5f, 0.5f, 0.5f);
  1491.             glTexCoord2f(1.0f, 1.0f);
  1492.             glVertex3f(152.0f, 0.0f, (float)wall);
  1493.             glTexCoord2f(0.0f, 1.0f);
  1494.             glVertex3f(148.0f, 0.0f, (float)wall);
  1495.             glTexCoord2f(0.0f, -15.0f);
  1496.             glVertex3f(148.0f, 200.0f, (float)wall);
  1497.             glTexCoord2f(1.0f, -15.0f);
  1498.             glVertex3f(152.0f, 200.0f, (float)wall);
  1499.             if(timeofday==0)
  1500.                 glColor3f(0.3f, 0.3f, 0.3f);
  1501.             else
  1502.                 glColor3f(0.1f, 0.1f, 0.1f);
  1503.             glTexCoord2f(1.0f, 1.0f);
  1504.             glVertex3f(152.0f, 200.0f, (float)wall);
  1505.             glTexCoord2f(0.0f, 1.0f);
  1506.             glVertex3f(148.0f, 200.0f, (float)wall);
  1507.             glTexCoord2f(0.0f, 0.0f);
  1508.             glVertex3f(148.0f, 200.0f, 0.0f);
  1509.             glTexCoord2f(1.0f, 0.0f);
  1510.             glVertex3f(152.0f, 200.0f, 0.0f);
  1511.         }
  1512.         else if(wall>=15)
  1513.         {
  1514.             if(timeofday==0)
  1515.                 glColor3f(0.9f, 0.9f, 0.9f);
  1516.             else
  1517.                 glColor3f(0.5f, 0.5f, 0.5f);
  1518.             glTexCoord2f(1.0f, 1.0f);
  1519.             glVertex3f(152.0f, 0.0f, 15.0f);
  1520.             glTexCoord2f(0.0f, 1.0f);
  1521.             glVertex3f(148.0f, 0.0f, 15.0f);
  1522.             glTexCoord2f(0.0f, -15.0f);
  1523.             glVertex3f(148.0f, 200.0f, 15.0f);
  1524.             glTexCoord2f(1.0f, -15.0f);
  1525.             glVertex3f(152.0f, 200.0f, 15.0f);
  1526.             if(timeofday==0)
  1527.                 glColor3f(0.3f, 0.3f, 0.3f);
  1528.             else
  1529.                 glColor3f(0.1f, 0.1f, 0.12f);
  1530.             glTexCoord2f(1.0f, 1.0f);
  1531.             glVertex3f(152.0f, 200.0f, 15.0f);
  1532.             glTexCoord2f(0.0f, 1.0f);
  1533.             glVertex3f(148.0f, 200.0f, 15.0f);
  1534.             glTexCoord2f(0.0f, 0.0f);
  1535.             glVertex3f(148.0f, 200.0f, 0.0f);
  1536.             glTexCoord2f(1.0f, 0.0f);
  1537.             glVertex3f(152.0f, 200.0f, 0.0f);
  1538.         }
  1539.     glEnd();
  1540.     glColor3f(0.5f, 0.5f, 0.5f);
  1541.     glPrint(291, 400, 0, "%d%d:%d%d", wall/25/60/10, wall/25/60%10, wall/25%60/10, wall/25%10);
  1542. }
  1543.  
  1544.  
  1545. void renderstatus(void)
  1546. {
  1547.     int i, x;
  1548.     static int liferotation=0;
  1549.     liferotation++;
  1550.     if(liferotation==360)
  1551.         liferotation=0;
  1552.  
  1553.     glTranslatef(-170, -80, -300);
  1554.     for(i=0; i<2; i++)
  1555.     {
  1556.         glEnable(GL_DEPTH_TEST);
  1557.         glEnable(GL_TEXTURE_2D);
  1558.         if(i==0)
  1559.             glBindTexture(GL_TEXTURE_2D, texture[REDTANK_TEXTURE]);
  1560.         if(i==1)
  1561.             glBindTexture(GL_TEXTURE_2D, texture[BLUETANK_TEXTURE]);
  1562.         glRotatef(-45, 1, 0, 0);
  1563.         for(x=0; x<player[i].lives; x++)
  1564.         {
  1565.             glTranslatef(20, 0, 0);
  1566.             glRotatef((float)liferotation, 0, 0, 1);
  1567.             if(x<7)
  1568.                 glCallList(model[TANK_MODEL]);
  1569.             glRotatef((float)-liferotation, 0, 0, 1);
  1570.         }
  1571.         glTranslatef((float)(-20*player[i].lives), 0, 0);
  1572.         glRotatef(45, 1, 0, 0);
  1573.         glDisable(GL_TEXTURE_2D);
  1574.         glDisable(GL_DEPTH_TEST);
  1575.  
  1576.  
  1577.         glEnable(GL_TEXTURE_2D);
  1578.         if(player[i].mode==BRICK_MODE)
  1579.             glColor3f(1.0f, 1.0f, 0.0f);
  1580.         else
  1581.             glColor3f(0.7f, 0.3f, 0.0f);
  1582.         glPrint(10+(320*i), 55, 1, "Bricks: %d", player[i].ammo.bricks);
  1583.         if(player[i].mode==MINE_MODE)
  1584.             glColor3f(1.0f, 1.0f, 0.0f);
  1585.         else
  1586.             glColor3f(0.7f, 0.3f, 0.0f);
  1587.         glPrint(10+(320*i), 40, 1, "Mines: %d", player[i].ammo.mines);
  1588.         if(player[i].mode==MISSLE_MODE)
  1589.             glColor3f(1.0f, 1.0f, 0.0f);
  1590.         else
  1591.             glColor3f(0.7f, 0.3f, 0.0f);
  1592.         glPrint(10+(320*i), 25, 1, "Missles: %d", player[i].ammo.missles);
  1593.         if(player[i].mode==GRENADE_MODE)
  1594.             glColor3f(1.0f, 1.0f, 0.0f);
  1595.         else
  1596.             glColor3f(0.7f, 0.3f, 0.0f);
  1597.         glPrint(10+(320*i), 10, 1, "Grenades: %d", player[i].ammo.grenades);
  1598.         glDisable(GL_TEXTURE_2D);
  1599.  
  1600.         glTranslatef(165, 0, 0);
  1601.     }
  1602.     glEnable(GL_DEPTH_TEST);
  1603.     glEnable(GL_TEXTURE_2D);
  1604. }
  1605.  
  1606.